package net.kong.sns.rest.client.model;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * @author <a href="mailto:lanhuai@gmail.com">Ning Yubin</a>
 * @version $Id: AbstractJsonAppObject.java,v 1.2.2.1 2009/12/09 09:47:20 wangyuanming Exp $
 */
public abstract class AbstractJsonAppObject implements BaseObject {
    private Set<String> initializedFields;

    protected abstract void processJsonObject(Map<String, Object> stringObjectMap);

    public void initialize(Map<String, Object> stringObjectMap, Set<String> initializedFields) {
        this.initializedFields = initializedFields;
        processJsonObject(stringObjectMap);
    }
    
    public void initialize(Map<String, Object> stringObjectMap, String[] initializedFields) {
        Set<String> initializedFieldsSet = new HashSet<String>();
        initializedFieldsSet.addAll(Arrays.asList(initializedFields));
        this.initialize(stringObjectMap, initializedFieldsSet);
    }

    public Set<String> getInitializedFields() {
        return initializedFields;
    }
}
